package com.hjx.xmlparser;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;

import java.io.File;

public class XmlParser {

    public static void main(String[] args) throws DocumentException {
        File xmlFile = new File("D:\\ws\\test\\out\\test\\resources\\real_name.xml");

        SAXReader reader = new SAXReader();
        Document document = reader.read(xmlFile);

//        List<Node> list = document.selectNodes("");

        Node node = document.selectSingleNode("//node[2]/node[2]/node[2]");

        String name = node.valueOf("@text");

        System.out.println(name);

        Node idcard = document.selectSingleNode("//node[2]/node[4]/node[3]");

        String id = idcard.valueOf("@text");

        System.out.println(id);
    }
}
